package imp

import (
	"bgs/cache/redisImp"
	"bgs/conf"
	"bgs/db"
	"bgs/grpc/client"
	commonGrpc "bgs/grpc/gen/service/common"
	"bgs/util"
	"context"
	warehouseService "bgs/service/warehouse"
	"go.uber.org/zap"
)

// CommonAPIService :grpc server proxy of common
type CommonAPIService struct {
	dao  *db.PgDao
	slog *zap.SugaredLogger
	commonGrpc.CommonOpServer
	warehouseService *warehouseService.WarehouseServiceImp
}

// NewCommonAPIService initialization
func NewCommonAPIService(
	pgdao *db.PgDao,
	slog *zap.SugaredLogger,
	vars *conf.VarsSection,
	proxy *client.GrpcClientProxy,
	adp *cache.Adapter,
	warehouseService *warehouseService.WarehouseServiceImp,
) *CommonAPIService {
	return &CommonAPIService{
		dao:  pgdao,
		slog: slog.With("module", "CommonAPIService"),
		warehouseService: warehouseService,
	}
}

// NewContextLogger create a SugaredLogger with contextvalue
func (s *CommonAPIService) NewContextLogger(ctx context.Context) *zap.SugaredLogger {
	return util.NewContextLogger(ctx, s.slog)
}
